const express = require('express');
const router = new express.Router();

/**
 * @param {Object} options
 * @param {} options.code 编号
 * @param {} options.dealerId 服务站Id(总代)
 * @param {} options.subDealerId 服务站Id(经销商)
 * @param {} options.brandId 品牌Id
 * @param {} options.status 旧件销毁单状态
 * @param {} options.beginCreateTime 创建时间-开始时间
 * @param {} options.endCreateTime 创建时间-结束时间
 * @param {} options.beginSubmitTime 提交时间-开始时间
 * @param {} options.endSubmitTime 提交时间-结束时间
 * @param {} options.beginApproveTime 审核时间-开始时间
 * @param {} options.endApproveTime 审核时间-结束时间
 * @param {} options.pageSize 每页数据量
 * @param {} options.pageIndex 指定页
 * @param {} options.sortField 排序字段
 * @param {} options.isDesc 倒序排列
 * @throws {Error}
 * @return {Promise}
 */
router.get('/forCurrentUser', async(req, res, next) => {
    const options = {
        code: req.query.code,
        dealerId: req.query.dealerId,
        subDealerId: req.query.subDealerId,
        brandId: req.query.brandId,
        status: req.query.status,
        beginCreateTime: req.query.beginCreateTime,
        endCreateTime: req.query.endCreateTime,
        beginSubmitTime: req.query.beginSubmitTime,
        endSubmitTime: req.query.endSubmitTime,
        beginApproveTime: req.query.beginApproveTime,
        endApproveTime: req.query.endApproveTime,
        pageSize: req.query.pageSize,
        pageIndex: req.query.pageIndex,
        sortField: req.query.sortField,
        isDesc: req.query.isDesc
    };
    const data = {
        message: 'message',
        payload: {
            content: [
                {
                    id: 'id297',
                    code: 'code298',
                    brandCode: '299',
                    dealerCode: 'dealerCode300',
                    dealerName: 'dealerName301',
                    status: 1,
                    createTime: '2019-09-19T08:23:26Z',
                    submitTime: '2019-09-19T08:23:26Z',
                    confirmTime: '2019-09-19T08:23:26Z',
                    approveTime: '2019-09-19T08:23:26Z',
                    remark: 'remark',
                    rowVersion: 'rowVersion',
                    options: ['update', 'abandon', 'submit', 'confirm', 'approve', 'print', 'add', 'confirmExport'
                    ]
                },
                {
                    id: 'id304',
                    code: 'code305',
                    brandCode: 'brandCode306',
                    dealerCode: 'dealerCode307',
                    dealerName: 'dealerName308',
                    status: 1,
                    createTime: '2019-09-19T08:23:26Z',
                    submitTime: '2019-09-19T08:23:26Z',
                    confirmTime: '2019-09-19T08:23:26Z',
                    approveTime: '2019-09-19T08:23:26Z',
                    remark: 'remark',
                    rowVersion: 'rowVersion',
                    options: ['update', 'abandon', 'submit', 'confirm', 'approve', 'print', 'add', 'confirmExport'
                    ]
                }
            ],
            pageIndex: null,
            pageSize: null,
            sort: null,
            totalElements: 50,
            totalPages: null
        }
    };
    res.json(data);
});
/**
 * @param {Object} options
 * @throws {Error}
 * @return {Promise}
 */
router.post('/', async(req, res, next) => {
    const options = {
    };
    const data = {
        message: 'message'
    };
    res.json(data);
});
/**
 * @param {Object} options
 * @param {} options.id id
 * @throws {Error}
 * @return {Promise}
 */
router.get('/export', (req, res) => {
    res.json({
        message: '导出成功',
        payload: 'Mock导出'
    });
});
router.get('/:id', async(req, res, next) => {
    const options = {
        id: req.params.id
    };
    const data = {
        message: 'message',
        payload: {
            id: 'id311',
            code: 'code312',
            brandId: 'brandId313',
            brandCode: 'brandCode313',
            dealerId: 'dealerId314',
            dealerCode: 'dealerCode314',
            dealerName: 'dealerName315',
            currency: 1,
            approverName: 'approverName318',
            approveTime: '2019-09-19T08:23:26Z',
            approveComment: 'approveComment',
            remark: 'remark',
            submitedComment: 'submitedComment',
            rowVersion: 'rowVersion',
            options: ['update', 'abandon', 'submit', 'confirm', 'approve', 'print', 'add', 'confirmExport'
            ],
            attachments: [
                {
                    fileId: 'fileId319',
                    fileName: 'fileName320'
                },
                {
                    fileId: 'fileId321',
                    fileName: 'fileName322'
                }
            ],
            details: [
                {
                    claimId: 'claimId323',
                    claimCode: 'claimCode324',
                    supplierCode: 'supplierCode316',
                    subDealerCode: 'subDealerCode325',
                    subDealerName: 'subDealerName326',
                    claimSignedRemark: 'string',
                    usedParts: [
                        {   
                            id: 'Id1',
                            usedPartBarCode: 'usedPartBarCode328',
                            usedPartCode: 'usedPartCode328',
                            usedPartName: 'usedPartName329',
                            usedPartDealCategory: 1,
                            remark: 'string',
                            unit: 'unit',
                            quantity: 1,
                        }
                    ]
                },
                {
                    claimId: 'claimId330',
                    claimCode: 'claimCode331',
                    supplierCode: 'supplierCode316',
                    subDealerCode: '',
                    subDealerName: '',
                    claimSignedRemark: 'string',
                    usedParts: [
                        {
                            id: 'Id2',
                            usedPartBarCode: 'usedPartBarCode327',
                            usedPartCode: 'usedPartCode328',
                            usedPartName: 'usedPartName329',
                            usedPartDealCategory: 1,
                            remark: 'string',
                            unit: 'unit',
                            quantity: 1,
                        }
                    ]
                }
            ]
        }
    };
    res.json(data);
});

router.get('/:id/export', (req, res) => {
    res.json({
        message: '导出成功'
    });
});
router.get('/:id/confirmExport', (req, res) => {
    res.json({
        message: '确认导出成功'
    });
});
/**
 * @param {Object} options
 * @param {} options.id id
 * @throws {Error}
 * @return {Promise}
 */
router.put('/:id', async(req, res, next) => {
    const options = {
        id: req.params.id
    };
    const data = {
        message: 'message'
    };
    res.json(data);
});
/**
 * @param {Object} options
 * @param {} options.id id
 * @throws {Error}
 * @return {Promise}
 */
router.put('/:id/submit', async(req, res, next) => {
    const options = {
        id: req.params.id
    };
    const data = {
        message: 'message'
    };
    res.json(data);
});
/**
 * @param {Object} options
 * @param {} options.id id
 * @throws {Error}
 * @return {Promise}
 */
router.put('/:id/abandon', async(req, res, next) => {
    const options = {
        id: req.params.id
    };
    const data = {
        message: 'message'
    };
    res.json(data);
});
/**
 * @param {Object} options
 * @param {} options.id id
 * @throws {Error}
 * @return {Promise}
 */
router.put('/:id/confirm', async(req, res, next) => {
    const options = {
        id: req.params.id
    };
    const data = {
        message: 'message'
    };
    res.json(data);
});
/**
 * @param {Object} options
 * @param {} options.id id
 * @throws {Error}
 * @return {Promise}
 */
router.put('/:id/pass', async(req, res, next) => {
    const options = {
        id: req.params.id
    };
    const data = {
        message: 'message'
    };
    res.json(data);
});
/**
 * @param {Object} options
 * @param {} options.id id
 * @throws {Error}
 * @return {Promise}
 */
router.put('/:id/reject', async(req, res, next) => {
    const options = {
        id: req.params.id
    };
    const data = {
        message: 'message'
    };
    res.json(data);
});/**
 * @param {Object} options
 * @param {} options.id id
 * @throws {Error}
 * @return {Promise}
 */
router.put('/:id/returnToPrev', async(req, res, next) => {
    const options = {
        id: req.params.id
    };
    const data = {
        message: 'message'
    };
    res.json(data);
});
module.exports = router;
